package org.example.video_word.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.video_word.entity.Admin;
import org.example.video_word.mapper.AdminMapper;

import org.example.video_word.service.AdminService;
import org.springframework.stereotype.Service;

@Service //注解当前类为被Spring容器管理的组件（业务层组件：javabean）
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {


    @Override
    public boolean add(Admin admin) {
        //根据提供的账号名查询是否存在重复的管理员 select * from admin where username=?
        //创建查询条件包装器
        QueryWrapper<Admin> query = Wrappers.query(Admin.class);
        //eq:equal 相等  ne:not equals 不相等
        query.eq("username",admin.getUsername());
        Admin a = getOne(query);
        if(a !=null){
            //账号已存在
            return false;
        }
        //执行添加
        return false;
    }

    @Override
    public boolean login(String username, String password) {
        return false;
    }
}
